<?php
/**
 * Created by PhpStorm.
 * User: yanghe
 * Date: 2016/4/27
 * Time: 19:04
 */
namespace App\Http\Controllers\Test;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\DB;



class ImageTestController extends Controller
{
    public static function addImage()
    {
		if (request::hasFile('image_file')) {
			$file = Request::file('image_file');
			$fileName = $file->getClientOriginalName();
			$storage_path ="/../storage/photo/";
			$path=$_SERVER['DOCUMENT_ROOT'].$storage_path;//$_SERVER['DOCUMENT_ROOT']获取当前文件的根目录
			Request::file('image_file')->move($path, $fileName);
			$data["image_path"]=$path;
			$data["image_name"]=$fileName;
			$res=DB::table("image")->insert($data);
			if($res)
			{
				return "成功";
			}
			else
			{
				return "失败";
			}

		}
		else
		{
			return "上传失败";
		}
    }
}